<?php

namespace App\Service\Wechat;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Service\Wechat\MaterialImage
 *
 * @property int $id 主键id
 * @property string|null $media_id 媒体id
 * @property string|null $url
 * @property string|null $name 图片原文件名
 * @property int|null $update_time 微信的更新时间
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Service\Wechat\MaterialImage whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Service\Wechat\MaterialImage whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Service\Wechat\MaterialImage whereMediaId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Service\Wechat\MaterialImage whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Service\Wechat\MaterialImage whereUpdateTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Service\Wechat\MaterialImage whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Service\Wechat\MaterialImage whereUrl($value)
 * @mixin \Eloquent
 */
class MaterialImage extends Model implements MaterialInterFace
{
    //
    protected $table = 'wx_material_image';

    public  function sync ()
    {
        // TODO: Implement sync() method.
    }

    public  static function upload ($data)
    {
        if(is_array($data)&&$data){
            $model = new MaterialImage();
            $model->media_id = $data['media_id'];
            $model->name = $data['name'];
            $model->url = $data['url'];
            $model->save();
        }

    }

    public static function getAll ()
    {
        $list = self::all();
        return $list?$list->toArray():[];
    }

    public static function getByMediaId ()
    {
        // TODO: Implement getByMediaId() method.
    }


}
